package com.draemon.haixiawenti.repository;

import com.yangzcp.userpojo.B_jinqiu;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;
import java.util.Map;

/**
 * <p></p>
 *
 * @author  yangz
 * @date    2016/11/13
 * @version latest
 */
public interface B_jinqiuRepository extends JpaRepository<B_jinqiu, Integer>{

    @Query("select ref_qiuyuan.name as qiuyuan, ref_qiuyuan.photo as qiuyuan_photo, ref_qiudui.name as qiudui, ref_qiudui.logo as qiudui_logo, count(*) as num from B_jinqiu where ref_saizhong.id=?1 and dian_qiu!=?2 group by ref_qiudui, ref_qiuyuan order by count(*) desc")
    public List<Map<String, Object>> findJinQiuBan(Integer saizhongId, Integer dian_flag);

    @Query("select ref_qiuyuan.name as qiuyuan, ref_qiuyuan.photo as qiuyuan_photo, ref_qiudui.name as qiudui, ref_qiudui.logo as qiudui_logo, count(*) as num from B_jinqiu where ref_saizhong.id=?1 and dian_qiu=?2 group by ref_qiudui, ref_qiuyuan ")
    public List<Map<String, Object>> findDianQiuban(Integer saizhongId, Integer dian_flag);

    @Query("from B_jinqiu where ref_saicheng.id=?1 and ref_qiudui.id=?2")
    public List<B_jinqiu> findBysaicheng(Integer saicheng_id, Integer qiudui_id);
}
